//Unit test for Smithy

#include "dominion.h"
#include "dominion_helpers.h"
#include "rngs.h"
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <stdlib.h>
#include <assert.h>

void randCards(struct gameState* state);

int main() {
	struct gameState state;
    int player = 0;
	int i,j,k, prevHandCount, prevDiscardCount;
	srand(time(NULL));
    
	randCards(&state);
	i = rand() % state.handCount[player];
	state.hand[player][i] = smithy;
		
	state.playedCardCount = 0;
	prevHandCount = state.handCount[player];
	prevDiscardCount = state.discardCount[player];

	j = cardEffect(smithy, 0, 0, 0, &state, i, NULL);
	assert(j == 0);
	assert(state.handCount[player] == (prevHandCount + 2));
	assert(state.playedCards[state.playedCardCount - 1] == smithy);

	printf("Passed.\n");
	return 0;
}

void randCards(struct gameState* state) {
	int i, p;
	
	for(p = 0; p < 4; ++p) {
		state->handCount[p] = 5;
		for (i = 0; i < state->handCount[p]; ++i) {
			state->hand[p][i] = rand() % 27;
		}
		
		state->discardCount[p] = 10;
		for (i = 0; i < state->discardCount[p]; ++i) {
			state->discard[p][i] = rand() % 27;
		}
		
		state->deckCount[p] = 10;
		for (i = 0; i < state->deckCount[p]; ++i) {
			state->deck[p][i] = rand() % 27;
		}
	}
}
